package com.java46.front.user.action;

import com.java46.admin.base.action.BaseAction;
import com.java46.admin.user.entity.UsersEntity;
import com.java46.front.user.service.UserService;
import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Result;

public class UserAction extends BaseAction {
    private String openId;

    public String getOpenId() {
        return openId;
    }

    public void setOpenId(String openId) {
        this.openId = openId;
    }

    @Action(value = "addUser")
    /*
    添加用户
     */
    public String addUser(){
        UserService userService = new UserService();
        //查询是否有该用户
        UsersEntity usersEntity = userService.queryUser(openId);

        if(usersEntity!=null){
            setSuccesResult("有该用户");
            return "json";
        }
        userService.addUser(openId);
        setSuccesResult("添加成功");
        return "json";
    }
}
